import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'

import projectModuleService from '/@/api/cn/core/coding/projectModuleService'

import type { ProjectModule } from '/@/model/cn/core/coding/eo/ProjectModule'
import type { ProjectModuleQO } from '/@/model/cn/core/coding/qo/ProjectModuleQO'
import type { ProjectModuleVO } from '/@/model/cn/core/coding/vo/ProjectModuleVO'

interface ProjectModuleState {
}

export const useProjectModuleStore = defineStore({
  id: 'projectModule',
  state: (): ProjectModuleState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<ProjectModule>): Promise<Res<ProjectModule>> {
      return new Promise<Res<ProjectModule>>((resolve, reject) => {
        projectModuleService.save(param).then((res: AxiosResponse<Res<ProjectModule>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<ProjectModule>): Promise<Res<ProjectModule>> {
      return new Promise<Res<ProjectModule>>((resolve, reject) => {
        projectModuleService.saveBatch(param).then((res: AxiosResponse<Res<ProjectModule>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<ProjectModule>): Promise<Res<ProjectModule>> {
      return new Promise<Res<ProjectModule>>((resolve, reject) => {
        projectModuleService.update(param).then((res: AxiosResponse<Res<ProjectModule>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<ProjectModule>): Promise<Res<ProjectModule>> {
      return new Promise<Res<ProjectModule>>((resolve, reject) => {
        projectModuleService.updateBatch(param).then((res: AxiosResponse<Res<ProjectModule>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<ProjectModule>): Promise<Res<ProjectModule>> {
      return new Promise<Res<ProjectModule>>((resolve, reject) => {
        projectModuleService.remove(param).then((res: AxiosResponse<Res<ProjectModule>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<ProjectModule>): Promise<Res<ProjectModule>> {
      return new Promise<Res<ProjectModule>>((resolve, reject) => {
        projectModuleService.removeBatch(param).then((res: AxiosResponse<Res<ProjectModule>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<ProjectModuleQO>): Promise<Res<ProjectModule>> {
      return new Promise<Res<ProjectModule>>((resolve, reject) => {
        projectModuleService.count(param).then((res: AxiosResponse<Res<ProjectModule>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<ProjectModuleQO>): Promise<Res<ProjectModule>> {
      return new Promise<Res<ProjectModule>>((resolve, reject) => {
        projectModuleService.pk(param).then((res: AxiosResponse<Res<ProjectModule>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<ProjectModuleQO>): Promise<Res<ProjectModule>> {
      return new Promise<Res<ProjectModule>>((resolve, reject) => {
        projectModuleService.query(param).then((res: AxiosResponse<Res<ProjectModule>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<ProjectModuleQO>): Promise<Res<ProjectModule>> {
      return new Promise<Res<ProjectModule>>((resolve, reject) => {
        projectModuleService.paging(param).then((res: AxiosResponse<Res<ProjectModule>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<ProjectModuleQO>): Promise<Res<ProjectModuleVO>> {
      return new Promise<Res<ProjectModuleVO>>((resolve, reject) => {
        projectModuleService.countVo(param).then((res: AxiosResponse<Res<ProjectModuleVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<ProjectModuleQO>): Promise<Res<ProjectModuleVO>> {
      return new Promise<Res<ProjectModuleVO>>((resolve, reject) => {
        projectModuleService.pkVo(param).then((res: AxiosResponse<Res<ProjectModuleVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<ProjectModuleQO>): Promise<Res<ProjectModuleVO>> {
      return new Promise<Res<ProjectModuleVO>>((resolve, reject) => {
        projectModuleService.queryVo(param).then((res: AxiosResponse<Res<ProjectModuleVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<ProjectModuleQO>): Promise<Res<ProjectModuleVO>> {
      return new Promise<Res<ProjectModuleVO>>((resolve, reject) => {
        projectModuleService.pagingVo(param).then((res: AxiosResponse<Res<ProjectModuleVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function useProjectModuleStoreWithout() {
  return useProjectModuleStore(store)
}
